package com.ken.astroboy.util;

import org.apache.commons.lang3.StringUtils;

public class SimpleCipher {

    public static String encrypt(String plaintext){
        
        String ciphertext = plaintext;
        
        ciphertext = StringUtils.replace(ciphertext, "@", "x");
        ciphertext = StringUtils.replace(ciphertext, "6", "R");
        ciphertext = StringUtils.replace(ciphertext, "3", "s");
        ciphertext = StringUtils.replace(ciphertext, "c", "t");
        ciphertext = StringUtils.replace(ciphertext, "a", "U");

        ciphertext = StringUtils.reverse(ciphertext);
         
        return ciphertext;
    }
    
    public static String decrypt(String ciphertext){  

        String plaintext = ciphertext;

        plaintext = StringUtils.reverse(plaintext);
        plaintext = StringUtils.replace(plaintext, "U", "a");
        plaintext = StringUtils.replace(plaintext, "t", "c");
        plaintext = StringUtils.replace(plaintext, "s", "3");
        plaintext = StringUtils.replace(plaintext, "R", "6");
        plaintext = StringUtils.replace(plaintext, "x", "@");

        
        return plaintext;
    }
}
